/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InfoEditGUI.java
 *
 * Created on Aug 1, 2009, 3:27:36 PM
 */
package JavaAssignment;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

/**
 *
 * @author Ishaan
 */
public class InfoEditGUI extends javax.swing.JFrame {

    Main m = new Main();
    GameData g;
    int i;
    GameData gameEdit;
    GameReview r;
    static int increment = 0;
    GameReview rx;


    /** Creates new form InfoEditGUI */
    public InfoEditGUI() {
        Main.pagecount = i;
        initComponents();
        g = (GameData) Main.gList.getGame(i);


    }

    public void iFieldSet(int i) {
        g = (GameData) Main.gList.getGame(i);
        gameNameEdit.setText(g.getGN());
        gameCategoryEdit.setText(g.gameCat);
        gamePriceEdit.setText(String.valueOf(g.gamePrice));
        gameDescriptionEdit.setText(g.gameDesc);
        gameReviewNoEdit.setText(String.valueOf(g.gameReviewNo));
        gameImageEdit.setText(g.gameImage);

    }

    public void addReview() {
        String gameReviewMag = JOptionPane.showInputDialog(null, "Enter Game Review Magazine: ");
        String gameReviewRating = JOptionPane.showInputDialog(null, "Enter Review Rating: ");        
        Main.gList.getGame(gameList.getSelectedIndex()).gameReview.addLast(new GameReview(gameReviewMag, gameReviewRating));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        gameList = new javax.swing.JList();
        gameAdd = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        gameRemove = new javax.swing.JButton();
        gameName = new javax.swing.JLabel();
        gamePrice = new javax.swing.JLabel();
        gameDescription = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        gameCategory = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        gameReviewNo = new javax.swing.JLabel();
        gameNameEdit = new javax.swing.JTextField();
        gamePriceEdit = new javax.swing.JTextField();
        gameDescriptionEdit = new javax.swing.JTextField();
        gameCategoryEdit = new javax.swing.JTextField();
        gameReviewNoEdit = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        revMag = new javax.swing.JLabel();
        gRating = new javax.swing.JLabel();
        magOutcome = new javax.swing.JLabel();
        ratingOutcome = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        gameReviewRemove = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        confirmEditInfo = new javax.swing.JButton();
        refreshButton = new javax.swing.JButton();
        revPrev = new javax.swing.JButton();
        revNext = new javax.swing.JButton();
        gameReviewAdd = new javax.swing.JButton();
        imageLabel = new javax.swing.JLabel();
        gameImageEdit = new javax.swing.JTextField();
        mainBack = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));
        jPanel1.setPreferredSize(new java.awt.Dimension(800, 500));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaassignment/sp_logo.jpg"))); // NOI18N

        gameList.setModel(new javax.swing.AbstractListModel() {
            public int getSize() { return Main.gList.getNumOfGames(); }
            public Object getElementAt(int i) { return Main.gList.getGame(i).gameName; }
        });
        gameList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                gameListValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(gameList);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        gameAdd.setText("+");
        gameAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gameAddActionPerformed(evt);
            }
        });

        jButton2.setText("jButton2");

        gameRemove.setText("-");

        gameName.setForeground(new java.awt.Color(255, 255, 255));
        gameName.setText("Name:");

        gamePrice.setForeground(new java.awt.Color(255, 255, 255));
        gamePrice.setText("Price:");

        gameDescription.setForeground(new java.awt.Color(255, 255, 255));
        gameDescription.setText("Description:");

        jLabel5.setForeground(new java.awt.Color(255, 255, 255));

        gameCategory.setForeground(new java.awt.Color(255, 255, 255));
        gameCategory.setText("Category:");

        jLabel7.setForeground(new java.awt.Color(255, 255, 255));

        gameReviewNo.setForeground(new java.awt.Color(255, 255, 255));
        gameReviewNo.setText("Review no:");

        revMag.setText("Review Magazine:");

        gRating.setText("Rating: ");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(gRating)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(ratingOutcome))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(revMag)
                        .addGap(48, 48, 48)
                        .addComponent(magOutcome)))
                .addContainerGap(99, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(revMag)
                    .addComponent(magOutcome))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(gRating)
                    .addComponent(ratingOutcome))
                .addContainerGap(27, Short.MAX_VALUE))
        );

        jLabel2.setBackground(new java.awt.Color(255, 255, 255));
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Reviews:");

        gameReviewRemove.setText("-");

        jButton1.setText("Reset");

        confirmEditInfo.setText("Confirm");
        confirmEditInfo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                confirmEditInfoActionPerformed(evt);
            }
        });

        refreshButton.setText("Refresh");
        refreshButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshButtonActionPerformed(evt);
            }
        });

        revPrev.setText("<");
        revPrev.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                revPrevActionPerformed(evt);
            }
        });

        revNext.setText(">");
        revNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                revNextActionPerformed(evt);
            }
        });

        gameReviewAdd.setText("+");
        gameReviewAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gameReviewAddActionPerformed(evt);
            }
        });

        imageLabel.setForeground(new java.awt.Color(255, 255, 255));
        imageLabel.setText("Image:");

        mainBack.setText("Back");
        mainBack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mainBackActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(188, 188, 188)
                        .addComponent(jLabel1))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(135, 135, 135)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(gameName)
                            .addComponent(gameDescription)
                            .addComponent(jLabel5)
                            .addComponent(jLabel7)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(gameCategory)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2)
                                    .addComponent(gameReviewNo))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(gameNameEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(refreshButton)
                                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(gameRemove, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(gameAdd, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(51, 51, 51)
                                        .addComponent(imageLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(gameImageEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addComponent(gameDescriptionEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 568, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(gameCategoryEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(gameReviewNoEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(65, 65, 65)
                                .addComponent(gamePrice)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(gamePriceEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                        .addComponent(revPrev)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(revNext))
                                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(gameReviewRemove, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(gameReviewAdd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(271, 271, 271)
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(confirmEditInfo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(mainBack)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addComponent(gameAdd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(gameRemove)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(refreshButton)
                .addGap(22, 22, 22)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(gameNameEdit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(gameName)
                    .addComponent(imageLabel)
                    .addComponent(gameImageEdit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(gameDescription)
                    .addComponent(gameDescriptionEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(21, 21, 21)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(gameCategory)
                    .addComponent(gameCategoryEdit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(2, 2, 2)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(gameReviewNo)
                            .addComponent(gameReviewNoEdit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(gamePrice)
                            .addComponent(gamePriceEdit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(17, 17, 17)
                                .addComponent(jLabel5)
                                .addGap(42, 42, 42)
                                .addComponent(jLabel7))
                            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(64, 64, 64)
                        .addComponent(gameReviewAdd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(gameReviewRemove)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(revPrev)
                            .addComponent(revNext)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(52, 52, 52)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton1)
                            .addComponent(confirmEditInfo)
                            .addComponent(mainBack))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 800, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 662, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void gameListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_gameListValueChanged
        iFieldSet(gameList.getSelectedIndex());
    }//GEN-LAST:event_gameListValueChanged

    private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshButtonActionPerformed
        this.setVisible(false);
        new InfoEditGUI().setVisible(true);
    }//GEN-LAST:event_refreshButtonActionPerformed

    private void gameAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gameAddActionPerformed
        Main.addGame();
    }//GEN-LAST:event_gameAddActionPerformed

    private void revNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_revNextActionPerformed
        g = (GameData) Main.gList.getGame(gameList.getSelectedIndex());
        increment++;
        rx = (GameReview) Main.gList.getGame(gameList.getSelectedIndex()).gameReview.get(increment);
        if (increment > Main.gList.getGame(gameList.getSelectedIndex()).gameReview.getNoOfElement()) {
            increment = 0;
        }
        magOutcome.setText(rx.gameReviewMag);
        ratingOutcome.setText(rx.gameReviewRating);
    }//GEN-LAST:event_revNextActionPerformed

    private void revPrevActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_revPrevActionPerformed
                  
        g = (GameData) Main.gList.getGame(gameList.getSelectedIndex());
        rx = (GameReview) Main.gList.getGame(gameList.getSelectedIndex()).gameReview.get(increment);
        if (increment > 0) {
            increment = 0;
        }
        increment++;
        magOutcome.setText(rx.gameReviewMag);
        ratingOutcome.setText(rx.gameReviewRating);
    }//GEN-LAST:event_revPrevActionPerformed

    private void gameReviewAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gameReviewAddActionPerformed
        addReview();
    }//GEN-LAST:event_gameReviewAddActionPerformed

    private void confirmEditInfoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmEditInfoActionPerformed
        // TODO add your handling code here:
        int tempIndex = gameList.getSelectedIndex();
        g = (GameData) Main.gList.getGame(tempIndex);    

        String tempN = gameNameEdit.getText();
        String tempC = gameCategoryEdit.getText();
        String tempD = gameDescriptionEdit.getText();
        String tempPs= gamePriceEdit.getText();
        double tempP = Double.parseDouble(tempPs);
        String tempI = gameImageEdit.getText();
        String tempRNos = gameReviewNoEdit.getText();
        int tempRN = Integer.parseInt(tempRNos);
        for(int x=0;x <= tempRN;x++){
            rx = (GameReview) Main.gList.getGame(tempIndex).gameReview.get(x);
            String tempRM = rx.gameReviewMag;
            String tempRR = rx.gameReviewRating;
            Main.gList.getGame(tempIndex).gameReview.addLast(new GameReview (tempRM, tempRR));
        }
        Main.gList.remove(0);
        Main.gList.add(tempIndex, new GameData());
    }//GEN-LAST:event_confirmEditInfoActionPerformed

    private void mainBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mainBackActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
        new MainPageGUI().setVisible(true);
    }//GEN-LAST:event_mainBackActionPerformed
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new InfoEditGUI().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton confirmEditInfo;
    private javax.swing.JLabel gRating;
    private javax.swing.JButton gameAdd;
    private javax.swing.JLabel gameCategory;
    private javax.swing.JTextField gameCategoryEdit;
    private javax.swing.JLabel gameDescription;
    private javax.swing.JTextField gameDescriptionEdit;
    private javax.swing.JTextField gameImageEdit;
    private javax.swing.JList gameList;
    private javax.swing.JLabel gameName;
    private javax.swing.JTextField gameNameEdit;
    private javax.swing.JLabel gamePrice;
    private javax.swing.JTextField gamePriceEdit;
    private javax.swing.JButton gameRemove;
    private javax.swing.JButton gameReviewAdd;
    private javax.swing.JLabel gameReviewNo;
    private javax.swing.JTextField gameReviewNoEdit;
    private javax.swing.JButton gameReviewRemove;
    private javax.swing.JLabel imageLabel;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel magOutcome;
    private javax.swing.JButton mainBack;
    private javax.swing.JLabel ratingOutcome;
    private javax.swing.JButton refreshButton;
    private javax.swing.JLabel revMag;
    private javax.swing.JButton revNext;
    private javax.swing.JButton revPrev;
    // End of variables declaration//GEN-END:variables
}
